<?php

/**
 * 
 * @desc This is standart exception class for validation errors
 * @author Barbushin Sergey http://www.linkedin.com/in/barbushin
 * 
 */
class Validator_Exception extends Exception {

	protected $errors = array();

	public function __construct(array $errors) {
		$this->errors = $errors;
		foreach ($errors as $var => $error) {
			$errorsInStrings[] = "$var($error)";
		}
		if ($errors) {
			parent::__construct('Validation failed with errors in fields: ' . implode(', ', $errorsInStrings));
		}
	}

	public function getErrors() {
		return $this->errors;
	}
}
